import Http from "@/http";

export function pageApi(params:any) {
    return Http.post('device/page', params)
}

export function saveApi(params:any) {
    return params.id ? Http.put('device/update', params) : Http.post('device/add', params)
}


export function deleteApi(id, syncDelAli=false) {
    return Http.delete('device/delete/' + id, {syncDelAli})
}

export function registerToAliApi(ids:number[]) {
    return Http.post('device/registerToAli', {ids})
}


export function bindMerchantApi(merchantId:number, ids:number[]) {
    return Http.post('device/bindMerchant', {merchantId, ids})
}

export function unbindMerchantApi(ids:number[]) {
    return Http.post('device/unbindMerchant', {ids})
}

export function setDeviceParamsApi(params) {
    return Http.post('device/setParams', params)
}


export function getDeviceApi(id) {
    return Http.get('device/detail/' + id)
}

export function getLastDataApi(id) {
    return Http.get('device/lastData/' + id)
}

export async function execCommandApi(data) {
    return Http.post('device/exec', data)
}

export function dataPageApi(params:any) {
    return Http.post('device/data/page', params)
}